import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getLecturerPage',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    theType: queryParams.theType,
    theLevel: queryParams.theLevel,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords
  }
  return request({
    url: '/getLecturerList',
    method: 'post',
    data: data
  })
}

// 新增
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      thename: val.thename, //姓名
      headPic: val.headPic, //头像照片
      exclusiveTitle: val.exclusiveTitle, // 专属头衔
      genderId: val.genderId, //性别 id  1-男 2-女
      genderVal: val.genderVal, //性别 选中的文本
      typeId: val.typeId, //讲师类型 id
      typeVal: val.typeVal, //讲师类型 选中的文本
      levelId: val.levelId, //讲师级别 id
      levelVal: val.levelVal, //讲师级别 选中的文本
      unitId: val.unitId, //工作单位 id
      workUnit: val.workUnit, //工作单位 选中的文本
      tel: val.tel, //联系电话
      idCard: val.idCard, //身份证号
      idCardImg1: val.idCardImg1, //身份证正面照片
      idCardImg2: val.idCardImg2, //身份证反面照片
      idCardImg: val.idCardImg, //身份证明证件照片
      trainPic: val.trainPic, //培训证明证书照片
      introduction: val.introduction, //个人简介
      workingExperience: val.workingExperience, //从业经历
      qualificationCert: val.qualificationCert, //资质证书
      goodDirection: val.goodDirection, //擅长方向
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addLecturer',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getLecturerData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      theid: val.theid, //id
      thename: val.thename, //姓名
      headPic: val.headPic, //头像照片
      exclusiveTitle: val.exclusiveTitle, //专属头衔
      genderId: val.genderId, //性别 id  1-男 2-女
      genderVal: val.genderVal, //性别 选中的文本
      typeId: val.typeId, //讲师类型 id
      typeVal: val.typeVal, //讲师类型 选中的文本
      levelId: val.levelId, //讲师级别 id
      levelVal: val.levelVal, //讲师级别 选中的文本
      unitId: val.unitId, //工作单位 id
      workUnit: val.workUnit, //工作单位 选中的文本
      tel: val.tel, //联系电话
      idCard: val.idCard, //身份证号
      idCardImg1: val.idCardImg1, //身份证正面照片
      idCardImg2: val.idCardImg2, //身份证反面照片
      idCardImg: val.idCardImg, //身份证明证件照片
      trainPic: val.trainPic, //培训证明证书照片
      introduction: val.introduction, //个人简介
      workingExperience: val.workingExperience, //从业经历
      qualificationCert: val.qualificationCert, //资质证书
      goodDirection: val.goodDirection, //擅长方向
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateLecturer',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delLecturer',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleLecturer',
    method: 'post',
    data: data
  })
}

// 获取下拉框数据
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getLecturerComboBox',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(val) {
  const data = {
    projectContent: {
      theid: val.theid,
      enable: val.enable
    }
  }
  return request({
    url: '/changeEnableLecturer',
    method: 'post',
    data: data
  })
}